Add column with default sort to prioritize new Agents in the index view

Andrew Cantino 9 年之前
父節點
當前提交
7476d7dcf1
共有 2 個文件被更改,包括 5 次插入1 次删除
  1. 1 1
      app/controllers/agents_controller.rb
  2. 4 0
      app/views/agents/_table.html.erb

+ 1 - 1
app/controllers/agents_controller.rb

@@ -4,7 +4,7 @@ class AgentsController < ApplicationController
4 4
   include SortableTable
5 5
 
6 6
   def index
7
-    set_table_sort sorts: %w[name last_check_at last_event_at last_receive_at], default: { name: :asc }
7
+    set_table_sort sorts: %w[name created_at last_check_at last_event_at last_receive_at], default: { created_at: :desc }
8 8
 
9 9
     @agents = current_user.agents.preload(:scenarios, :controllers).reorder(table_sort).page(params[:page])
10 10
 

+ 4 - 0
app/views/agents/_table.html.erb

@@ -2,6 +2,7 @@
2 2
   <table class='table table-striped'>
3 3
     <tr>
4 4
       <th><%= sortable_column 'name', 'asc' %></th>
5
+      <th><%= sortable_column 'created_at', 'desc', name: 'Age' %></th>
5 6
       <th>Schedule</th>
6 7
       <th><%= sortable_column 'last_check_at', name: 'Last Check' %></th>
7 8
       <th><%= sortable_column 'last_event_at', name: 'Last Event Out' %></th>
@@ -24,6 +25,9 @@
24 25
           <% end %>
25 26
         </td>
26 27
         <td class='<%= "agent-unavailable" if agent.unavailable? %>'>
28
+          <%= time_ago_in_words agent.created_at %>
29
+        </td>
30
+        <td class='<%= "agent-unavailable" if agent.unavailable? %>'>
27 31
           <% if agent.can_be_scheduled? %>
28 32
             <%= agent_schedule(agent, ',<br/>') %>
29 33
           <% else %>